package com.springapp.fed.rule.engine;

import com.springapp.fed.domain.model.UserData;
import org.drools.RuleBase;
import org.drools.RuleBaseFactory;
import org.drools.WorkingMemory;
import org.drools.compiler.PackageBuilder;
import org.springframework.stereotype.Component;

import java.io.FileReader;
import java.io.FilterReader;

/**
 * Created with IntelliJ IDEA.
 * User: WENKY
 * Date: 10/31/13
 * Time: 10:47 PM
 * To change this template use File | Settings | File Templates.
 */
@Component
public class RuleManager {
   public int getFraudRate(UserData userData) throws Exception{
       PackageBuilder pb=new PackageBuilder();
       pb.addPackageFromDrl(new FileReader("classpath:rules.drl"));
       RuleBase rb= RuleBaseFactory.newRuleBase();
       rb.addPackage(pb.getPackage());
       WorkingMemory workingMemory=null;
//       WorkingMemory workingMemory = rb.newWorkingMemory();
//       workingMemory.assertObject(userData);
       workingMemory.fireAllRules();
       workingMemory.dispose();
       int fraudrate = 1;
        return fraudrate;
    }

}
